<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:param name="param_pageTitle"
		value="#{messages.luyuan_crm_menu_order}" />
	<ui:param name="param_navigationUrl"
		value="/luyuan/sale/layout/navigationSale.jsf" />

	<ui:define name="road">
		<span>我的订单</span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<h:form>
				<rg:areaPanel type="searchPanel">
					<rg:fieldSet column="auto">
						<rg:inputText value="#{orderSaleAction.uuid}" label="订单号" />
						
						<rg:calendar value="#{orderSaleAction.startDate}" label="开始日期"
							datePattern="yyyy-MM-dd" showApplyButton="false" />
						<rg:calendar value="#{orderSaleAction.endDate}" label="结束日期"
							datePattern="yyyy-MM-dd" showApplyButton="false" />
						<rg:selectOne id="status" enableEmpty="true" label="订单状态" 
							value="#{orderSaleAction.orderStatus}"
							converter="#{orderStatusConverter}"
							itemsProvider="#{orderStatusProvider}" />
						<h:commandButton styleClass="button"
							value="#{messages.luyuan_crm_query}" />
					</rg:fieldSet>
				</rg:areaPanel>
				
				<div style="margin-top: 10px;text-align:right;" >
					<h:commandButton styleClass="button larger" value="新建订单" action="/luyuan/sale/addOrder.jsf" />
				</div>
				
				<rg:titlePanel headerTitle="我的订单"
					style="margin-top: 10px;" needButton="true" readonly="false">

					<rg:table id="orderTable" value="#{orderSaleAction.orderTableModel}"
						var="item">
						<rg:column property="id" title="订单号" sortable="false"/>
						<rg:column property="orderType" title="订单类型"
							converter="#{orderTypeConverter}"  sortable="false"/>
						<rg:column property="createTime" title="购买时间"  sortable="false"
							datePattern="yyyy-MM-dd HH:mm" converter="#{dateConverter}" />
						<rg:column property="orderStatus" title="订单状态"
							converter="#{orderStatusConverter}"  sortable="false"/>
						<rg:column property="customer.name" title="购买会员"  sortable="false"/>
						<rg:column property="oldAmount" title="总额"  sortable="false"/>
						<rg:column property="amount" title="成交额"  sortable="false"/>
						<rg:column type="oper" title="#{messages.luyuan_crm_operator}">
							<ul class="links">
								<li>
									<h:outputLink value="/luyuan/sale/orderViewForSale.jsf">
										<f:param name="id" value="#{item.id}"/>
										详细订单
									</h:outputLink>
								</li>
								<li>
									<h:commandLink value="更新订单" action="#{orderSaleAction.startWizard(item)}" 
										rendered="#{item.orderStatus eq 'UPDATING'}"/>
								</li>
								<li>
									<h:commandLink  onclick="UI.instance.showDialog({id:'confirmStatus', src:'/luyuan/sale/updateOrderForSaleReceived.jsf?uuid=#{item.id}'});"
										rendered="#{item.orderStatus eq 'DELIVERED'}" value="确认收货">
									</h:commandLink>
								</li>
								<li>
									<h:commandLink onclick="UI.instance.showDialog({id:'returnedStatus', src:'/luyuan/sale/updateOrderForSaleRejected.jsf?uuid=#{item.id}'});"
										rendered="#{item.orderStatus eq 'DELIVERED'}" value="客户退货">
									</h:commandLink>
								</li>
							</ul>
						</rg:column>
					</rg:table>
				</rg:titlePanel>
			</h:form>
		</rg:areaPanel>
		<a:form>
			<a:jsFunction name="reRenderOrderTable" reRender="orderTable" />
		</a:form>
	</ui:define>
</ui:composition>